#include <scheme.h>
#include "config.h" 
#include "../../include/const_def.h"
#include "../../include/path_def.h"
#include "policy_buffer.h"
#include "ioctl.h"
#include "file_table.h"
#include "lsm.h"
#include "globals.h"
#include "audit_list.h"
#include "init.h"
 
 
int system_init(void)
{
	int retval = -1;
	int nflag = -1;

	global_module_init();
	config_module_init();
	audit_list_module_init();
	
	if(0 != ioctl_module_init()){
		goto DONE;
	}
	
	if(0 != file_table_module_init()){
		goto DONE;
	}
	policy_module_init();
	 
	nflag = read_whitelist(HASHLIST_PATH, MAXLIST, DIGEST_SIZE);
	if(nflag){
		printk("read whitelist error %d\n", retval);
	}

	
	nflag = lsm_hook();
	if(nflag != 0){
		goto DONE;
	}
		
	retval = 0;
DONE:
	return retval;
}


void system_destroy(void)
{
	lsm_unhook();
	policy_module_destroy();
	ioctl_module_destroy();
	file_table_module_destroy();
	audit_list_module_destroy();
	config_module_destroy();
	global_module_destroy();
	return;
}


